/**
 * 
 */
package com.axt.dbaudit.action.cfg;

import java.util.List;

import org.apache.struts2.json.annotations.JSON;

import com.axt.dbaudit.bean.cfg.IpGroupBean;
import com.axt.dbaudit.model.cfg.IpGroup;
import com.axt.soa.action.BaseAction;
import com.axt.soa.msg.types.MsgParam;

/**
 * @author axt
 * 
 */
public class IpGroupAction extends BaseAction {
	private IpGroupBean ipGroupBean = new IpGroupBean();
	private List<IpGroup> ipGroups = null;

	@JSON(name = "ipgroups")
	public List<IpGroup> getIpGroups() {
		return ipGroups;
	}

	public void setIpGroups(List<IpGroup> ipGroups) {
		this.ipGroups = ipGroups;
	}

	@JSON(name = "errcode")
	public int getErrcode() {
		return errcode;
	}

	@JSON(name = "errinfo")
	public String getErrinfo() {
		return errinfo;
	}

	private int au_GroupID;
	private String au_item_id;
	private String au_IP;
	private String au_ipname;
	private String au_mac;
	private String au_comname;
	private String au_createtime;
	private String au_modifytime;
	private String au_Name;
	private int au_ID;
	private String IdList;

	public String getIdList() {
		return IdList;
	}

	public void setIdList(String idList) {
		IdList = idList;
	}

	public IpGroupBean getClIpGroupBean() {
		return ipGroupBean;
	}

	public void setClIpGroupBean(IpGroupBean clIpGroupBean) {
		this.ipGroupBean = clIpGroupBean;
	}

	public int getAu_GroupID() {
		return au_GroupID;
	}

	public void setAu_GroupID(int au_GroupID) {
		this.au_GroupID = au_GroupID;
	}

	public String getAu_item_id() {
		return au_item_id;
	}

	public void setAu_item_id(String au_item_id) {
		this.au_item_id = au_item_id;
	}

	public String getAu_IP() {
		return au_IP;
	}

	public void setAu_IP(String au_IP) {
		this.au_IP = au_IP;
	}

	public String getAu_ipname() {
		return au_ipname;
	}

	public void setAu_ipname(String au_ipname) {
		this.au_ipname = au_ipname;
	}

	public String getAu_mac() {
		return au_mac;
	}

	public void setAu_mac(String au_mac) {
		this.au_mac = au_mac;
	}

	public String getAu_comname() {
		return au_comname;
	}

	public void setAu_comname(String au_comname) {
		this.au_comname = au_comname;
	}

	public String getAu_createtime() {
		return au_createtime;
	}

	public void setAu_createtime(String au_createtime) {
		this.au_createtime = au_createtime;
	}

	public String getAu_modifytime() {
		return au_modifytime;
	}

	public void setAu_modifytime(String au_modifytime) {
		this.au_modifytime = au_modifytime;
	}

	public String getAu_Name() {
		return au_Name;
	}

	public void setAu_Name(String au_Name) {
		this.au_Name = au_Name;
	}

	public int getAu_ID() {
		return au_ID;
	}

	public void setAu_ID(int au_ID) {
		this.au_ID = au_ID;
	}

	/**
	 * @param args
	 *            添加客户端分组Action
	 */
	public String addGroupName() {

		ipGroupBean.addGroupName(serverPath, au_Name);
		setErrcode(ipGroupBean.getErrcode());
		setErrinfo(ipGroupBean.getErrinfo());

		return MsgParam.SUCCESS;

	}

	/**
	 * 添加客户端IPAction
	 * 
	 * @param au_comname
	 * @param au_mac
	 * @param au_IP
	 */
	public String addClientIp() {

		ipGroupBean.addClientIp(serverPath, au_comname, au_mac, au_GroupID,
				au_IP, au_ipname);
		setErrcode(ipGroupBean.getErrcode());
		setErrinfo(ipGroupBean.getErrinfo());

		return MsgParam.SUCCESS;

	}

	/**
	 * 删除客户端IPAction
	 */
	public String deleteClientIpById() {
		ipGroupBean.deleteClientIpById(serverPath, au_ID);
		setErrcode(ipGroupBean.getErrcode());
		setErrinfo(ipGroupBean.getErrinfo());

		return MsgParam.SUCCESS;
	}

	/**
	 * 删除客户端分组
	 */
	public String deleteGroupById() {

		ipGroupBean.deleteGroupById(serverPath, au_GroupID);
		setErrcode(ipGroupBean.getErrcode());
		setErrinfo(ipGroupBean.getErrinfo());

		return MsgParam.SUCCESS;

	}

	/**
	 * 重命名组
	 */
	public String modifyGroupName() {
		ipGroupBean.modifyGroupName(serverPath, au_Name, au_GroupID);
		setErrcode(ipGroupBean.getErrcode());
		setErrinfo(ipGroupBean.getErrinfo());

		return MsgParam.SUCCESS;

	}

	/**
	 * 修改客户端IP
	 */
	public String modifyClientIP() {
		ipGroupBean
				.modifyClientIP(serverPath, au_comname, au_mac, au_IP, au_ID);
		setErrcode(ipGroupBean.getErrcode());
		setErrinfo(ipGroupBean.getErrinfo());

		return MsgParam.SUCCESS;

	}

	/**
	 * 获取IP_group和item列表Action
	 */
	public String queryIpGroupAndItem() {

		setIpGroups(ipGroupBean.queryIpGroupAndItem(serverPath));
		setErrcode(ipGroupBean.getErrcode());
		setErrinfo(ipGroupBean.getErrinfo());

		return MsgParam.SUCCESS;

	}
}
